<template>
	<view class="content">
		<!-- <image src="../../static/images/detail/img.png" mode="widthFix" class="bg-img"></image> -->
		<view class="block swiper-block">
			<swiper autoplay="true" indicator-dots="true" indicator-color="#999" indicator-active-color="#fff"
				class="swiper-item">
				<swiper-item :item-id="item.id" v-for="(item,index) in info.swiperList" :key="item.id" class="bg-item">
					<image :src="item" class="bg-img"></image>
				</swiper-item>
			</swiper>
		</view>
		<CustomNav :custom="custom" :title="title" :isBack="true" backColor="#fff" :topBgColor="topBgColor"
			color="#fff">
		</CustomNav>
		<view class="info-block">
			<view class="info-item">
				<view class="title FangZhengHanZhenGuangBiaoJianTi">{{info.title}}</view>
				<view class="cont-detail">{{info.description}}</view>
			</view>
			<view class="info-item1">
				<view class="info-list" @click="callPhone">
					<view class="info-left">
						<view class="iconfont icon-a-31dianhua"></view>
						<view class="title">{{info.phone}}</view>
					</view>
					<view class="iconfont icon-a-gengduo1" style="color: #999;font-size: 36rpx;font-weight: bold;">
					</view>
				</view>
				<view class="info-list">
					<view class="info-left">
						<view class="iconfont icon-a-shijian1"></view>
						<view class="title">{{info.time_range}}</view>
					</view>
				</view>
				<view class="info-list" @click="openLocation">
					<view class="info-left">
						<view class="iconfont icon-a-dizhi1"></view>
						<view class="title">{{info.address}}</view>
					</view>
					<view class="iconfont icon-a-gengduo1" style="color: #999;font-size: 36rpx;font-weight: bold;">
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getCustomNavData
	} from '@/util/util.js'
	import {
		getServiceDetailApi
	} from '@/api/housekeeping.js'
	export default {
		data() {
			return {
				custom: null,
				topBgColor: 'rgba(0,0,0,0)',
				info: {
					face_url: '',
					title: '',
					description: '',
					phone: '',
					time_range: '',
					address: '',
					swiperList: []
				},
				id: 0,
				title: ''
			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: this.info.phone,
					success() {
						console.log('拨打成功了');
					},
					fail() {
						console.log('拨打失败了');
					}
				})
			},
			getDetailApi() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				const id = this.id
				getServiceDetailApi(id).then(data => {
					uni.hideLoading()
					this.info = data[0]
					this.info.swiperList = data[0].attachment.split(',')
				}).catch(() => {
					uni.hideLoading()
				})
			},
			openLocation() {

				uni.openLocation({
					longitude: Number(this.info.longitude),
					latitude: Number(this.info.latitude),
					name: this.info.title,
					address: this.info.address,
					fail: (err) => {
						console.log(err);
						this.showToast('打开失败，请重试！');
					}
				})
			}
		},
		onPageScroll(e) {
			if (e.scrollTop >= 1) {
				this.topBgColor = '#BA1519'
			} else {
				this.topBgColor = 'rgba(0,0,0,0)';
			}
		},
		onLoad(e) {
			this.custom = getCustomNavData();
			this.id = e.id
			this.title = e.title
			this.getDetailApi()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		.block.swiper-block {
			height: 650rpx;
			width: 100%;

			.swiper-item {
				width: 100%;
				height: 650rpx;

				.bg-item {
					width: 100%;
					height: 100%;

					.bg-img {
						width: 100%;
						height: 100%;
					}
				}
			}
		}

		.info-block {
			display: flex;
			flex-direction: column;
			background: #F7F6F9;
			margin-top: -100rpx;
			border-radius: 60rpx;
			position: relative;
			padding: 30rpx;

			.info-item {
				background-color: #fff;
				padding: 30rpx;
				border-radius: 20rpx;
				margin-bottom: 30rpx;

				.title {
					font-size: 34rpx;
					margin-bottom: 20rpx;
				}

				.cont-detail {
					font-size: 30rpx;
					line-height: 60rpx;
				}
			}


			.info-item1 {
				background-color: #fff;
				padding: 30rpx;
				border-radius: 20rpx;
				margin-bottom: 30rpx;
				display: flex;
				flex-direction: column;

				.info-list {
					display: flex;
					align-items: center;
					justify-content: space-between;
					height: 120rpx;
					border-bottom: 1px solid #F7F6F9;

					.info-left {
						display: flex;
						align-items: center;

						.iconfont {
							font-size: 40rpx;
							margin-right: 20rpx;
							color: #000;
						}

						.title {
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}
					}
				}

				.info-list:last-child {
					border-bottom: none;
				}
			}
		}
	}
</style>